<template>
  <div id="app">
    <el-row class="bodyBox">
      <el-col :span="4">
        <div class="width_96 margin_top_10">
          <div class="width_100 padding_bottom_10 border_bottom">
            <el-input placeholder="输入关键字进行过滤" v-model="filterText"></el-input>
          </div>
          <el-tree class="tree_list margin_top_10" :data="treeData" node-key="id" default-expand-all
            :expand-on-click-node="false">
            <span class="custom-tree-node" slot-scope="{ node, data }">
              <span>{{ node.label }}</span>
              <el-dropdown @command="e => commandFn(e, data)">
                <span class="el-dropdown-link"><i class="el-icon-more el-icon--right"></i></span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="add">添加</el-dropdown-item>
                  <el-dropdown-item command="edit">编辑</el-dropdown-item>
                  <el-dropdown-item command="del">删除</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </span>
          </el-tree>
        </div>
      </el-col>
      <el-col :span="20" class="small_box">
        <div class="width_100 list">
          <el-row class="width_98 display_flex align_items_center margin_top_10">
            <el-col :span="18" class="font_size_26">科里(天津)科技有限公司(北京分公司)（15人）</el-col>
            <el-col :span="6">
              <div class="display_flex align_items_center justify_content_flex_end tab_title">
                <div>修改名称</div>
                <div>|</div>
                <div>添加子部门</div>
                <div>|</div>
                <div>设置负责人</div>
              </div>
            </el-col>
          </el-row>
        </div>
        <div class="width_98 box">
          <el-row class="display_flex" :gutter="10">
            <el-col :span="8">
              <el-button type="primary" size="mini" @click="add()">添加成员</el-button>
              <el-button type="primary" size="mini" plain>批量导出</el-button>
              <el-button type="danger" size="mini" plain>删除</el-button>
            </el-col>
            <el-col :span="4"></el-col>
            <el-col :span="6">
              <el-date-picker v-model="time" class="width_100" type="daterange" align="right" unlink-panels
                range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions">
              </el-date-picker>
            </el-col>
            <el-col :span="6" class="display_flex align_items_center">
              <el-input placeholder="搜索成员/手机号/部门" prefix-icon="el-icon-search" v-model="input2">
              </el-input>
              <el-dropdown @command="e => commandFn(e, treeData)">
                <i class="el-icon-s-fold margin_left_10"></i>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item command="add">全部</el-dropdown-item>
                  <el-dropdown-item command="edit">正常成员</el-dropdown-item>
                  <el-dropdown-item command="del">禁用成员</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </el-col>
          </el-row>
        </div>
        <div v-if="list.length != 0">
          <el-table :data="list" class="margin_top_10 table_list" @selection-change="handleSelectionChange"
            style="width: 100%">
            <el-table-column type="selection"></el-table-column>
            <el-table-column prop="name" label="姓名"></el-table-column>
            <el-table-column prop="date" label="手机号"></el-table-column>
            <el-table-column prop="date" label="部门"></el-table-column>
            <el-table-column prop="date" label="分润比例"></el-table-column>
            <el-table-column prop="date" label="商户数"></el-table-column>
            <el-table-column prop="date" label="商户交易总额"></el-table-column>
            <el-table-column prop="date" label="佣金"></el-table-column>
            <el-table-column prop="date" label="余额"></el-table-column>
          </el-table>
          <el-pagination hide-on-single-page @size-change="handleSizeChange" @current-change="handleCurrentChange"
            :current-page="currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="10"
            layout="total, sizes, prev, pager, next, jumper" :total="pageTotal">
          </el-pagination>
        </div>
        <el-empty description="当前部门无任何成员" v-if="list.length == 0">
          <el-button type="primary">添加成员</el-button>
        </el-empty>
      </el-col>
    </el-row>
    <div style="width: 100%;height: 200px;"></div>
    <el-dialog :title="sub_title" :visible.sync="dialogVisible" :show-close="false" width="30%">
      <el-form>
        <el-row>
          <el-col :span="24">
            <el-form-item label="部门名称：" prop="name">
              <el-input placeholder="请输入部门名称" v-model="form.name"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  get,
  post,
  formatterCellval,
  pickerOptions
} from "../../../util/request.js"
export default {
  name: "App",
  data() {
    var treeData = [
      {
        id: 1,
        label: "一级 1",
        children: [
          {
            id: 4,
            label: "二级 1-1",
            children: [
              {
                id: 9,
                label: "三级 1-1-1"
              },
              {
                id: 10,
                label: "三级 1-1-2"
              }
            ]
          }
        ]
      },
      {
        id: 2,
        label: "一级 2",
        children: [
          {
            id: 5,
            label: "二级 2-1"
          },
          {
            id: 6,
            label: "二级 2-2"
          }
        ]
      },
      {
        id: 3,
        label: "一级 3",
        children: [
          {
            id: 7,
            label: "二级 3-1"
          },
          {
            id: 8,
            label: "二级 3-2"
          }
        ]
      }
    ]

    return {
      treeData: JSON.parse(JSON.stringify(treeData)),
      formatterCellval,
      filterText: "",
      time: "",
      pickerOptions,
      input2: "",
      currentPage: 1,
      pageTotal: 0,
      lisst: [],
      list: [
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        },
        {
          name: "张三",
          date: "2023-10-26",
          address: "山东省济南市历下区泉城路",
          num: 12
        }
      ],
      form: {},
      sub_title: "",
      dialogVisible: false
    }
  },
  mounted() { },
  methods: {
    commandFn(res, e) {
      console.log(res, e)
      if (res == "add") {
        this.sub_title = "新增部门"
        this.dialogVisible = true
      } else if (res == "edit") {
        this.sub_title = "修改部门"
        this.dialogVisible = true
      } else if (res == "del") {
        console.log(res, e)
        this.$confirm("确定删除" + e.label + "部门？", "删除部门", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            this.$message({
              type: "success",
              message: "删除成功!"
            })
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除"
            })
          })
      }
    },
    treeClickFn() { },
    add() {
      this.$router.push({
        name: "organizationDetail"
      })
    },
    handleSelectionChange() { },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
    }
  }
}
</script>

<style scoped="true">
.centreBox {
  min-height: 100vh;
  background-color: #f1f4f9;
}

.bodyBox {
  background-color: #fff;
  min-height: 100vh;
}

.table_list>>>.el-table__cell {
  text-align: center;
}

.tree_list>>>.custom-tree-node {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  padding-right: 8px;
}

.tree_list>>>.el-tree-node__content:hover {
  background-color: red !important;
}

.list>>>.font_size_26 {
  font-size: 26px;
}

.list>>>.tab_title {
  font-size: 12px;
  color: #0067d9;
}

.list>>>.tab_title div {
  margin-right: 10px;
}

.small_box>>>.list {
  padding: 10px 0;
}

.small_box>>>.box {
  padding: 10px;
  border-radius: 6px;
  background-color: rgba(236, 242, 254, 1);
}
</style>
